
const fs = require('fs')
const { getCurrentDate } = require('./wrongTime.js');

function errorMiddleware(err, req, res, next) {
    console.log('error middleware')
    console.log(err.name);
    console.log(err.message);
    let data = `\n\n时间：${getCurrentDate(2)} - 错误名称：${err.name}--${err.message}`
    fs.appendFileSync('./error.log', data)
    next();
}

module.exports = errorMiddleware
